/**
 * Copyright (c) 2016-2019 人人开源 All rights reserved.
 *
 * https://www.renren.io
 *
 * 版权所有，侵权必究！
 */

package io.renren.modules.app.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.common.utils.R;
import io.renren.modules.app.annotation.Login;
import io.renren.modules.app.entity.dto.AppProductFormDTO;
import io.renren.modules.app.entity.dto.AppProductListDTO;
import io.renren.modules.app.service.AppProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("app/product")
@Api(tags  = "APP商品接口")
public class AppProductController {

    @Autowired
    AppProductService appProductService;

    /**
     * 条件查询分页获取商品
     */
    @ApiOperation("条件查询分页获取商品")
    @GetMapping("/list")
    public R getProducList(AppProductFormDTO form){
        Page page = appProductService.getProducList(form);
        return R.ok().put("page", page);
    }

    /**
     * 根据id获取商品信息
     */
    @ApiOperation("根据id获取商品信息")
    @GetMapping("/list/{id}")
    public R getProducList(@PathVariable("id") Long id){
        return R.ok().put("data", appProductService.getById(id));
    }

}
